<?php
//Config
require_once( 'conf/config.php' );
require_once( 'conf/rewriteRules.php' );

//Requires
require_once( 'lib/UriRewriter.class.php' );
require_once( 'lib/ActionRouter.php' );
require_once( 'lib/ProtocolFunction.class.php' );
require_once( 'lib/Page.class.php' );
require_once( 'lib/smarty/Smarty.class.php' );
if( $_CONF['db']['dbms']  == 'mysql' ){
	require_once( 'lib/MysqlDB.class.php' );
}
require_once( 'lib/Logger.class.php' );
require_once( 'lib/User.class.php' );

//Redirects to installation process
_checkInstallation( );

require_once( 'conf/dbconfig.php' );

//Starts the session
session_start( );

//Session user istance creation
$_httpUser = new User( );

//Bootstrap
$_actionRouter = new ActionRouter( );

//Utils
function _checkInstallation( ){
	global $CONF;
	$_uriRewriter = new RewriteEngine( );		
	$status = json_decode( file_get_contents( 'conf/status.js' ) );
	if( !$status ){
		header("Location: {$_uriRewriter->url}install.php");
		exit;
	}
	if( !$status['installed'] ){
		header("Location: {$_uriRewriter->url}install.php");
		exit;
	}
}

?>